﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SBSimpleLib.Utils
{

    public class Logger {

        private static String TAG = "KB";

        public const int DEBUG = 4;
        public const int INFO = 3;
        public const int WARN = 2;
        public const int ERROR = 1;

        public static int LVL = DEBUG; // Debug

        public static void debug(String tag, String message) 
        {
            log(DEBUG, concatTags(tag, message));
        }

        public static void info(String tag, String message)
        {
            log(INFO, concatTags(tag, message));
        }

        public static void warn(String tag, String message)
        {
            log(WARN, concatTags(tag, message));
        }

        public static void error(String tag, String message)
        {
            log(ERROR, concatTags(tag, message));
        }

        public static void log(int level, String message) {

            String strLevel = "DEFAULT";

            if (level <= LVL)
            {
                switch (level)
                {
                    case DEBUG:
                        strLevel = "DEBUG";
                        break;
                    case INFO:
                        strLevel = " INFO";
                        break;
                    case WARN:
                        strLevel = " WARN";
                        break;
                    case ERROR:
                        strLevel = "ERROR";
                        break;
                }
                Console.WriteLine("[" + strLevel + "] " + message);
            }
        }

        private static String concatTags(String tag, String message)
        {
            return TAG + "-" + tag + " " + message;
        }

    }
}
